import streamlit as st
import streamlit_model.streamlit_utils.session_utils as ss


def login_page():
    # 关键：让登录页保持居中，避免“全屏拉长”
    st.set_page_config(
        page_title="登录",
        page_icon="✅",
        layout="centered"  # 居中布局，防止表单被拉伸
    )

    st.title("登录")
    with st.form("login_form"):
        username = st.text_input("用户名")
        password = st.text_input("密码", type="password")
        submitted = st.form_submit_button("登录")

        if submitted:
            if ss.login(username, password):
                st.rerun()
            else:
                st.error("用户名或密码错误")
